# patial rthing function
# 
# data.ppp:  start point pattern
# P:         Data giving the retention probabilities, either a 
#            single number, or a coord function, or im map.
# condition: Conditions given the unchange points. should be the same
#            length of points in data.ppp
#
# Author: Guochun Shen
# Data:   2011-12-18
# Project:spatial statistic
# Email:  shenguochun@gmail.com
###############################################################################


partial_rthin=function(data.ppp,P,condition){
	unchange.ppp=data.ppp[condition]
	changeable.ppp=data.ppp[!condition]
	if(changeable.ppp$n!=0){
		thin.ppp=rthin(changeable.ppp,P)
		#new.ppp=superimpose(unchange.ppp,thin.ppp)
		new.ppp=unique(thin.ppp)
	}else{
		warnings("no points meet condition")
		new.ppp=unchange.ppp
	}
	
	return(new.ppp)
}
